﻿var ppt_act = false;
var sound_act = false;
var video_act = false;

function CheckForm() {
    if (ppt_act) {
        if (form1.PicFileUpload != null && form1.PicFileUpload.value != "") {
            if (form1.PicFileUpload.value.match(/^(.*)(\.)(.{1,8})$/)[3] != 'ppt' && form1.PicFileUpload.value.match(/^(.*)(\.)(.{1,8})$/)[3] != 'pptx') {
                alert("必须为ppt或者pptx格式！ ");
                return false;
            }
        }
        else {
            alert("文档不能为空！");
            return false;
        }
    }

    if (sound_act) {
        if (form1.SoundFileUpload != null && form1.SoundFileUpload.value != "") {
            if (form1.SoundFileUpload.value.match(/^(.*)(\.)(.{1,8})$/)[3] != 'mp3' ) {
                alert("必须为mp3格式！ ");
                return false;
            }
        }
//        else {
//            alert("音频不能为空！");
//            return false;
//        }
    }

    if (video_act) {
        if (form1.VideoFileUpload != null && form1.VideoFileUpload.value != "") {
            if (form1.VideoFileUpload.value.match(/^(.*)(\.)(.{1,8})$/)[3] != 'wmv' && form1.VideoFileUpload.value.match(/^(.*)(\.)(.{1,8})$/)[3] != 'avi') {
                alert("必须为wmv或者avi格式！ ");
                return false;
            }
        }
//        else {
//            alert("文档不能为空！");
//            return false;
//        }
    }

    var courseid = document.getElementById("CourseSlt").value;
    var serialNumber = document.getElementById("SerialNumberTxt").value;

    if (courseid == "-1" || serialNumber == "" || isNaN(serialNumber)) {
        alert("信息填写错误");
        return false;
    } else {
        return true;
    }

}

function editPPT() {
    ppt_act = true;
    document.getElementById("p_update").value = "t";
    document.getElementById("PicFileUpload").style.display = "";
    document.getElementById("pptbackdiv").style.display = "";
    document.getElementById("pptdiv").style.display = "none";
}
function cancelPPT() {
    ppt_act = false;
    document.getElementById("p_update").value = "f";
    document.getElementById("PicFileUpload").style.display = "none";
    document.getElementById("pptbackdiv").style.display = "none";
    document.getElementById("pptdiv").style.display = "";
}

function editSound() {
    sound_act = true;
    document.getElementById("s_update").value = "t";
    document.getElementById("SoundFileUpload").style.display = "";
    document.getElementById("soundbackdiv").style.display = "";
    document.getElementById("sounddiv").style.display = "none";
}
function cancelSound() {
    sound_act = false;
    document.getElementById("s_update").value = "f";
    document.getElementById("SoundFileUpload").style.display = "none";
    document.getElementById("soundbackdiv").style.display = "none";
    document.getElementById("sounddiv").style.display = "";
}

function editVideo() {
    video_act = true;
    document.getElementById("v_update").value = "t";
    document.getElementById("VideoFileUpload").style.display = "";
    document.getElementById("videobackdiv").style.display = "";
    document.getElementById("videodiv").style.display = "none";
}
function cancelVideo() {
    video_act = false;
    document.getElementById("v_update").value = "f";
    document.getElementById("VideoFileUpload").style.display = "none";
    document.getElementById("videobackdiv").style.display = "none";
    document.getElementById("videodiv").style.display = "";
}